<!DOCTYPE html>
<html>
<head>
    <block name="include">
        <include file="Public:header"/>
    </block>
</head>
<body>
<br>
<div class="layui-container">
    <div class="layui-row">
        <div class="layui-col-sm9 LAY_preview">
            <form class="layui-form layui-form-pane">
                <input type="hidden" name="id" required class="layui-input" value="{$data.id}">
                <input type="hidden" name="path" value="{$data.path}">
                <div class="layui-form-item">
                    <label class="layui-form-label ">排序:</label>
                    <div class="layui-input-block">
                        <input type="text" name="order" required lay-verify="required" placeholder="排序"
                               autocomplete="off" class="layui-input" value="{$data.order}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">文件名:</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" placeholder="文件名"
                               autocomplete="off" class="layui-input" value="{$data.name}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">分类:</label>
                    <div class="layui-input-block">
                        <select name="cat_id">
                            <volist name="cat" id="vo">
                                <if condition="$vo['id'] eq $data['cat_id']">
                                    <option value="{$vo.id}" selected>{$vo.name}</option>
                                    <else/>
                                    <option value="{$vo.id}">{$vo.name}</option>
                                </if>
                            </volist>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="formEdit">立即提交</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<block name="include">
    <include file="Public:footer"/>
</block>
<script>
    layui.use('form', function () {
        var form = layui.form;

        form.on('submit(formEdit)', function (data) {
            layui.use(['jquery', 'layer'], function () {
                var $ = layui.$
                    , layer = layui.layer;
//                console.log(data.field);
                $.ajax({
                    url: "{:U('Download/editFilePost')}",
                    data: data.field,
                    dataType: 'json',
                    type: 'post',
                    success: function (data) {
                        if (data.status == 1) {
                            parent.location.href = "{:U('Download/index')}";
                        } else {
                            layer.msg(data.info);
                        }
                    }
                });
            });
            return false;
        });
    });

    layui.use('laydate', function () {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#create_date',
            type: 'date'
        });
    });
</script>
</body>
</html>